Section -Prerequisites
	# Check Java
	readRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" CurrentVersion
	StrCmp $0 "" 0 JavaInstalled
	DetailPrint "Java is not installed"
	
	# Check if silent and just install
	IfSilent installJava
    messageBox MB_YESNO "You need to install Java first. Do you want to download and install it now?" IDYES installJava IDNO JavaAbort
	
	installJava:
	DetailPrint "Downloading Java installer"
	NSISdl::download http://javadl.sun.com/webapps/download/AutoDL?BundleId=39494 $TEMP\javainstaller.exe
	Pop $R0
	  StrCmp $R0 "success" JavaDownloaded
		MessageBox MB_OK "Java download failed: $R0"
		DetailPrint "Java download failed: $R0"
		Quit
	
	JavaDownloaded:
	DetailPrint "Installing Java"
	ExecWait '$TEMP\javainstaller.exe /quiet' $0
	IntCmp $0 0 JavaInstalled 0
	DetailPrint "Java Installation failed"
	MessageBox MB_OK "Java Installation failed"
	
	JavaAbort:
	Abort
	
	JavaInstalled:
	
	
	
	# Check DotNet
	readRegStr $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client" Version
	StrCmp $0 "" 0 DotNetInstalled
	DetailPrint "DotNet 4 is not installed"
	
	# Check if silent and just install
	IfSilent installDotNet
    messageBox MB_YESNO "You need to install DotNet 4 first. Do you want to download and install it now?" IDYES installDotNet IDNO DotNetAbort
	
	installDotNet:
	DetailPrint "Downloading DotNet installer"
	NSISdl::download http://download.microsoft.com/download/1/B/E/1BE39E79-7E39-46A3-96FF-047F95396215/dotNetFx40_Full_setup.exe $TEMP\dotnetinstaller.exe
	Pop $R0
	  StrCmp $R0 "success" DotNetDownloaded
		MessageBox MB_OK "DotNet download failed: $R0"
		DetailPrint "DotNet download failed: $R0"
		Quit
	
	DotNetDownloaded:
	DetailPrint "Installing DotNet"
	ExecWait '$TEMP\dotnetinstaller.exe' $0
	IntCmp $0 0 DotNetInstalled 0
	DetailPrint "DotNet Installation failed"
	MessageBox MB_OK "DotNet Installation failed"
	
	DotNetAbort:
	Abort
	
	DotNetInstalled:
SectionEnd